#! /bin/bash

# use external mirror, remove this script when using a mirror from CD

cat <<EOM > $target/etc/apt/sources.list
# external mirror
deb MIRRORURL $ubuntudist main restricted universe multiverse
deb MIRRORURL $ubuntudist-updates main restricted universe multiverse
deb MIRRORURL $ubuntudist-security main restricted universe multiverse
#deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $ubuntudist stable
#deb http://ppa.launchpad.net/ansible/ansible/ubuntu $ubuntudist main

#Oracle Java 8
#deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main
#deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main

#Ambari VERSION_NUMBER=2.6.1.3-3
#deb http://public-repo-1.hortonworks.com/ambari/ubuntu16/2.x/updates/2.6.1.3 Ambari main
#HDP VERSION_NUMBER=2.6.4.0-91
#deb http://public-repo-1.hortonworks.com/HDP/ubuntu16/2.x/updates/2.6.4.0 HDP main
#deb http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/ubuntu16 HDP-UTILS main
EOM

# determine a fast mirror for Ubuntu
list=$(curl -s http://mirrors.ubuntu.com/mirrors.txt)
mirror=$(netselect $list | awk '{print $2}')
sed -i -e "s#MIRRORURL#$mirror#" $target/etc/apt/sources.list
